package cn.learn.dubbo3.enhance.processor;

import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.TypeConverter;
import org.springframework.beans.factory.InjectionPoint;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.UnsatisfiedDependencyException;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.beans.factory.annotation.InjectionMetadata;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @Desc
 * @Author XieWei
 * @Date 2022/1/26 16:54
 */
public class ServiceRefrenceFieldElement extends InjectionMetadata.InjectedElement{
    protected final AnnotationAttributes attributes;

    public ServiceRefrenceFieldElement(Member member, @Nullable PropertyDescriptor pd, AnnotationAttributes attributes) {
        super(member, pd);
        this.attributes = attributes;
    }


    @Override
    protected void inject(Object bean, @Nullable String beanName, @Nullable PropertyValues pvs) throws Throwable {
        //从容器中获取对应的代理bean
        Object injectedObject = null;//getInjectedObject(attributes, bean, beanName, getInjectedType(), this);

        Field field = (Field) this.member;
        ReflectionUtils.makeAccessible(field);
        field.set(bean, injectedObject);
    }


}
